<template>
<div>
    <el-form :model="inputForm" ref="inputForm" v-loading="loading"   :disabled="formReadOnly"
             label-width="120px">
      <el-row  :gutter="15">
        <el-col :span="24">
            <el-form-item label="物料编码" prop="sparepartsCoding"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sparepartsCoding" placeholder="请填写物料编码"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="物料名称" prop="sparepartsName"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sparepartsName" placeholder="请填写物料名称"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="规格型号" prop="sparepartsType"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sparepartsType" placeholder="请填写规格型号"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="计量单位" prop="sparepartsUnit"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sparepartsUnit" placeholder="请填写计量单位"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="使用单位" prop="sparepartsUesUnit"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sparepartsUesUnit" placeholder="请填写使用单位"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="ABC分类" prop="sparepartsAbcCategory"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sparepartsAbcCategory" placeholder="请填写ABC分类"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="上线日期" prop="sparepartsUpDate"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sparepartsUpDate" placeholder="请填写上线日期"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="下线日期" prop="sparepartsDownDate"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sparepartsDownDate" placeholder="请填写下线日期"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="单价" prop="sparepartsUnitCost"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sparepartsUnitCost" placeholder="请填写单价"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="使用年限" prop="sparepartsUseYear"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sparepartsUseYear" placeholder="请填写使用年限"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="报废说明" prop="sparepartsScrapState"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sparepartsScrapState" placeholder="请填写报废说明"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="审核人" prop="sparepartsChekPeople"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sparepartsChekPeople" placeholder="请填写审核人"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-date-picker
              v-model="value1"
              type="date" format class="input-class">
          </el-date-picker>
            <el-form-item label="审核时间" prop="sparepartsCheckTime"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sparepartsCheckTime" placeholder="请填写审核时间"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="12">
            <el-form-item label="处理意见" prop="sparepartsOpinion"
                :rules="[
                 ]">
                <el-select v-model="inputForm.sparepartsOpinion" placeholder="请选择"  style="width: 100%;">
                <el-option v-for="sparepartsOpinion in $dictUtils.getDictList('spareparts_audit_opinion')" :label="sparepartsOpinion.label" :value="sparepartsOpinion.value" :key="sparepartsOpinion.value" ></el-option>
                </el-select>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="意见说明" prop="sparepartsOpinionState"
                :rules="[
                 ]">
          <el-input type="textarea" v-model="inputForm.sparepartsOpinionState" placeholder="请填写意见说明"     ></el-input>
           </el-form-item>
        </el-col>
        </el-row>
    </el-form>
</div>
</template>

<script>
  export default {
    data () {
      return {
        value1: '',
        title: '',
        method: '',
        loading: false,
        inputForm: {
          id: '',
          sparepartsCoding: '',
          sparepartsName: '',
          sparepartsType: '',
          sparepartsUnit: '',
          sparepartsUesUnit: '',
          sparepartsAbcCategory: '',
          sparepartsUpDate: '',
          sparepartsDownDate: '',
          sparepartsUnitCost: '',
          sparepartsUseYear: '',
          sparepartsScrapState: '',
          sparepartsChekPeople: '',
          sparepartsCheckTime: '',
          sparepartsOpinion: '',
          sparepartsOpinionState: ''
        }
      }
    },
    props: {
      businessId: {
        type: String,
        default: ''
      },
      formReadOnly: {
        type: Boolean,
        default: false
      }
    },
    components: {
    },
    watch: {
      'businessId': {
        handler (newVal) {
          if (this.businessId) {
            this.init(this.businessId)
          } else {
            this.$nextTick(() => {
              this.$refs.inputForm.resetFields()
            })
          }
        },
        immediate: true,
        deep: false
      }
    },
    methods: {
        // 默认显示今天
      getdatatime () {
      this.value1 = new Date()
      },
       mounted () {
          let that = this
          that.getdatatime()
        },
      init (id) {
        if (id) {
          this.loading = true
          this.inputForm.id = id
          this.$nextTick(() => {
            this.$refs.inputForm.resetFields()
            this.$http({
              url: `/spareparts/material/sparepartsScrapAudit/queryById?id=${this.inputForm.id}`,
              method: 'get'
            }).then(({data}) => {
              this.inputForm = this.recover(this.inputForm, data.sparepartsScrapAudit)
              this.loading = false
            })
          })
        }
      },
      // 表单提交
      saveForm (callback) {
        this.$refs['inputForm'].validate((valid) => {
          if (valid) {
            this.loading = true
            this.$http({
              url: `/spareparts/material/sparepartsScrapAudit/save`,
              method: 'post',
              data: this.inputForm
            }).then(({data}) => {
              if (data && data.success) {
                callback(data.businessTable, data.businessId)
              }
            })
          }
        })
      }
    }
  }
</script>
  <style>
 .input-class{
    width: 150px;
    height: 30px;
  }
    </style>
